Testing .NET Connections
Once the .NET Client is installed, you can connect from your application to your database with a connection string.
The following example illustrates connecting to the underlying Sybase database using the .NET Client from an application developed in Visual Studio .NET. If you are connecting using a different ADO.NET data provider or connecting from the command line, the specific details vary.
If you are using Visual Studio .NET:
- In the Solution Explorer, right-click References; then, click Add Reference.
- Select the DataDirect Technologies SequeLink .NET Client in the component list.
- Click OK. The Solution Explorer now includes a reference for the .NET Client.
- Check the beginning of your application. If the data provider's namespace is not present, add it, as shown in the following code fragments:
C#
// Access SequeLink Server
using System.Data;
using DDTek.SequeLink;
Visual Basic
' Access SequeLink Server
Imports System.Data
Imports DDTek.SequeLink
- Add the connection information for your server and exception handling code, as shown in the following C# code fragment. (Refer to the SequeLink Developer's Reference for the connection string options.)
C#
DBConn = new SequeLinkConnection("Host=sydney;
Port=19998;User ID=test01;Password=test01;
Database=test");try
{
DBConn.Open();
Console.WriteLine ("Connection successful!");
}
// Display any exceptions
catch (SequeLinkException ex)
{
// Connection failed
Console.WriteLine (ex.Message);
return;
}
Visual Basic
Dim Conn As New SequeLinkConnection("Host=bowhead;
Port=19996;User ID=test01;Password=test01;
Database=test")Try
'Open the connection
Conn.Open()
MessageBox.Show("Connection successful!")
Catch SLex As SequeLinkException
'Connection failed
MessageBox.Show(SLex.Message, "SequeLink Exception")
End Try
- Close the connection.
C#
// Close the connection
DBConn.Close();
Visual Basic
'Close the connection
Conn.Close()
For information about using connection strings and connection string options, refer to the SequeLink Developer's Reference.